<?php
/**
	模板详情页下载记录JSON
**/

$cfg_NotPrintHead = false;
header("Content-Type: text/html; charset=utf-8");
include_once (dirname(__FILE__)."/../include/common.inc.php");

include_once (dirname(__FILE__)."/../include/json.class.php");

$wheresql = " WHERE op.arcid > 0 AND op.product='archive'";
$sql = "SELECT op.*,ms.*,addon.* FROM `#@__member_operation` op
        LEFT JOIN `#@__archives` ms ON ms.id = op.arcid
		LEFT JOIN `#@__addonsoft` addon ON addon.aid = op.arcid
        $wheresql order by op.mtime DESC LIMIT 0,10 ";
		
$dsql->Execute('op',$sql);

while($row = $dsql->GetArray('op')) {
	if($row['dows']==''){
		$row['dows'] = 0;
	}
	if($row['litpic']==''){
		$row['litpic'] = $cfg_cmsurl.'/images/defaultpic.gif';
	}
	if($row['title']==''){
		$row['title'] = '无标题';
	}
	if($row['resolution']==''){
		$row['resolution'] = '0';
	}
	if($row['id']!=''){
        $row['arcurl'] = $GLOBALS['cfg_phpurl'].'/view.php?aid='.$row['id'];
    }else{
		$row['arcurl'] = 'javascript:alert("该资源已不存在");';
	}
	$arr['list'][] = array(
	'id' => $row['id'],
	'title' => $row['title'],
	'arcurl' => $row['arcurl'],
	'dows' => $row['dows'],
	'resolution' => $row['resolution'],
	'litpic' => $row['litpic'],
	'pubdate' => date('Y-m-d H:i',$row['pubdate'])
	);
}

$json = new Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS);
echo json_encode($arr);

?>